package com.controller;

import com.mapper.MainMenuMapper;
import com.service.MainMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
public class MainMenuController {
    @Autowired
    private MainMenuService mainMenuService;
    //查询员工列表
    @RequestMapping(value="/mainmenu",method= RequestMethod.GET)
    public ModelAndView getAllMainmenu(){
        List<MainMenuMapper> list=mainMenuService.getMainMenu();
        ModelAndView mv=new ModelAndView();
        mv.addObject("list",list);
        mv.setViewName("mainMenu");
        return mv;
    }
    @RequestMapping(value="/mainmenu/{id}",method=RequestMethod.GET)
    public String toGo(@PathVariable("id") Integer id){
        if (id==1){
            return "login";
        }else if(id==2){
            return "register";
        }else if(id==3){
        	return "secondMenu";
        }
        return null;
    }
}
